/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.jomijushi.fid.dominio;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author miguel
 */
@Entity
@Table(name = "fid_cliente", catalog = "fid", schema = "")

@PrimaryKeyJoinColumn(name="fid_persona_empresa_id")
@DiscriminatorValue("cliente")

//@NamedQueries({@NamedQuery(name = "FidCliente.findAll", query = "SELECT f FROM FidCliente f"), @NamedQuery(name = "FidCliente.findByFidPersonaEmpresaId", query = "SELECT f FROM FidCliente f WHERE f.fidPersonaEmpresaId = :fidPersonaEmpresaId"), @NamedQuery(name = "FidCliente.findByCantVentas", query = "SELECT f FROM FidCliente f WHERE f.cantVentas = :cantVentas"), @NamedQuery(name = "FidCliente.findByFechaPrimeraCompra", query = "SELECT f FROM FidCliente f WHERE f.fechaPrimeraCompra = :fechaPrimeraCompra"), @NamedQuery(name = "FidCliente.findBySaldo", query = "SELECT f FROM FidCliente f WHERE f.saldo = :saldo")})
public class FidCliente extends FidPersonaEmpresa implements Serializable {
    private static final long serialVersionUID = 1L;

    @Column(name = "cantVentas")
    private Integer cantVentas;
    @Column(name = "fechaPrimeraCompra")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechaPrimeraCompra;
    @Column(name = "saldo")
    private Double saldo;
    @OneToMany(mappedBy = "fidClienteFidPersonaEmpresaId")
    private List<FidPedidoVenta> fidPedidoVentaList;
    @JoinColumn(name = "fid_tipo_cliente_id", referencedColumnName = "id")
    @ManyToOne
    private FidTipoCliente fidTipoClienteId;
    @JoinColumn(name = "fid_persona_empresa_id", referencedColumnName = "id", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private FidPersonaEmpresa fidPersonaEmpresa;

    public FidCliente() {
    }

    /*
    public FidCliente(Integer fidPersonaEmpresaId) {
        this.fidPersonaEmpresaId = fidPersonaEmpresaId;
    }

    public Integer getFidPersonaEmpresaId() {
        return fidPersonaEmpresaId;
    }

    public void setFidPersonaEmpresaId(Integer fidPersonaEmpresaId) {
        this.fidPersonaEmpresaId = fidPersonaEmpresaId;
    }
    */
    @Override
    public Integer getCantVentas() {
        return cantVentas;
    }

    @Override
    public void setCantVentas(Integer cantVentas) {
        this.cantVentas = cantVentas;
    }

    @Override
    public Date getFechaPrimeraCompra() {
        return fechaPrimeraCompra;
    }

    @Override
    public void setFechaPrimeraCompra(Date fechaPrimeraCompra) {
        this.fechaPrimeraCompra = fechaPrimeraCompra;
    }

    @Override
    public Double getSaldo() {
        return saldo;
    }

    @Override
    public void setSaldo(Double saldo) {
        this.saldo = saldo;
    }

    public List<FidPedidoVenta> getFidPedidoVentaList() {
        return fidPedidoVentaList;
    }

    public void setFidPedidoVentaList(List<FidPedidoVenta> fidPedidoVentaList) {
        this.fidPedidoVentaList = fidPedidoVentaList;
    }

    public FidTipoCliente getFidTipoClienteId() {
        return fidTipoClienteId;
    }

    public void setFidTipoClienteId(FidTipoCliente fidTipoClienteId) {
        this.fidTipoClienteId = fidTipoClienteId;
    }

    public FidPersonaEmpresa getFidPersonaEmpresa() {
        return fidPersonaEmpresa;
    }

    public void setFidPersonaEmpresa(FidPersonaEmpresa fidPersonaEmpresa) {
        this.fidPersonaEmpresa = fidPersonaEmpresa;
    }

    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof FidCliente)) {
            return false;
        }
        FidCliente other = (FidCliente) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.jomijushi.fid.dominio.FidCliente[fidPersonaEmpresaId=" + id + "]";
    }

}
